package demo.zzz.com.captureactivity.utils;

import android.annotation.TargetApi;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;


import com.uuzuche.lib_zxing.activity.ZXingLibrary;

import java.util.concurrent.TimeUnit;
import java.util.logging.Level;

/**
 * Created by Administrator on 2018\11\29 0029.
 */

public class MyApplication extends Application {
	private static Context context;

	@Override
	public void onCreate() {
		super.onCreate();
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
			initNotificationChannel();
		}
		context = getApplicationContext();
		//初始化ZXING包
		ZXingLibrary.initDisplayOpinion(this);
	}

	public static Context getContext(){
		return context;
	}

	private void initNotificationChannel(){
		String channelId = "WanxiangCarrier";
		String channelName = "WanxiangCarrier";
		int importance = NotificationManager.IMPORTANCE_DEFAULT;
		createNotificationChannel(channelId,channelName,importance);
	}
	@TargetApi(Build.VERSION_CODES.O)
	private void createNotificationChannel(String channelId, String channelName, int importance) {
		NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
		NotificationManager notificationManager = (NotificationManager) getSystemService(
				NOTIFICATION_SERVICE);
		notificationManager.createNotificationChannel(channel);
	}
}
